<?php
if($_POST['act']){
    $title = @mysql_escape_string($_POST['title']);
    $rule_detail = @mysql_escape_string($_POST['rule_detail']);
    $description = @mysql_escape_string($_POST['description']);
    $status = $_POST['status'];
    $id = $_POST['id'];
    if($_POST['act']=='edit' && $id>0){//编辑
        $sql = "update ".MICROSHOPTASK." set title='{$title}',rule_detail='{$rule_detail}',description='{$description}' where id={$id}";
        $db->query($sql);
    }
    if($_POST['act']=='save'){//新增
        $sql = "insert into ".MICROSHOPTASK." (`title`,`rule_detail`,`description`,`status`,`create_user`) values('{$title}','{$rule_detail}','{$description}','{$status}','{$_SESSION['ADMIN_USER']}')";
        $db->query($sql);
    }
    
    msg('?m=micro_shop&s=task_list.php');
}

$de = array();
if($_GET['act']=='edit' && $_GET['id']>0){
    $sql = "select * from ".MICROSHOPTASK." where id={$_GET['id']}";
    $db->query($sql);
    $de = $db->fetchRow();
}
$tpl->assign('de',$de);
$tpl->assign('config',$config);
$tpl->display('task_add_edit.htm');